<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/12
 * Time: 14:30
 * 查询机构总课时、总价格、剩余课时数  还要算 已经 消耗的课时数=总课时数-剩余课时数  再算一下单价 总价格/总课时
 */

$oa_oseid = $route->bodyParams['oa_oseid'];  //机构id
$startTime = $route->bodyParams['startTime'];
$endTime = $route->bodyParams['endTime'];
if($startTime&&$endTime){
    $time_condition = "AND oo.oo_create_time between ". $startTime ." AND " . $endTime;
}else{
    $time_condition = "";
}

//$sql = "select SUM(oscr_total_class) as class_hour,
//                SUM(oscr_course_price) as price,
//                SUM(oscr_surplus_class) as surplus_class
//                from v_art_order_course_info where oc_oesid = ".$oa_oseid;

$sql = "select oo.oo_id,oo.oo_course_times,oo.oo_oesid,oc.oc_type,oscr.oscr_surplus_class,oo.oo_course_price from art_oa_order as oo LEFT JOIN art_oa_student_course_record as oscr
on (oscr.oscr_ooid = oo.oo_id)  JOIN art_oa_course as oc on (oo.oo_ocid = oc.oc_id) where oo.oo_oesid = ".$oa_oseid ." ".$time_condition;


$re=$db->mysqlDB->query($sql);


$response->responseData(true,$re);